package cc.fs.zhihuapp.ui.activity.demo;

import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;


import cc.fs.zhihuapp.R;
import cc.fs.zhihuapp.ui.activity.helper.BaseActivity;
import cc.fs.zhihuapp.ui.receivers.SmsContent;

/**
 * Created by fostion on 1/4/16.
 * 测试过基本没有什么问题实际使用需要遇到详细时使用
 */
public class SmsReceiverActivity extends BaseActivity {

    private Button btn;

    public void e(String log) {
        Log.e("--SmsReceiverActivity--", log);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_sms_receiver);

        btn = (Button) findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SmsContent.register(SmsReceiverActivity.this, new SmsContent.SmsCallback() {
                    @Override
                    public void run(String msg) {
                        e(" ----   "+" 截取到的短信内容是 "+msg);

                    }
                });
            }
        });
    }

    @Override
    public void handler(Message msg) {
    }

    @Override
    protected void onDestroy() {
        SmsContent.unregister(this);
        super.onDestroy();
    }
}
